package com.mt.demo.controller;

import com.mt.demo.domain.AjaxResult;
import com.mt.demo.domain.MtVoteQuestion;
import com.mt.demo.domain.TableDataInfo;
import com.mt.demo.service.IMtVoteQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 投票问题Controller
 * 
 * @author gary
 * @date 2025-08-11
 */
@RestController
@RequestMapping("/mt/mtQuestion")
public class MtVoteQuestionController extends BaseController
{
    @Autowired
    private IMtVoteQuestionService mtVoteQuestionService;

    /**
     * 查询投票问题列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MtVoteQuestion mtVoteQuestion)
    {
        startPage();
        List<MtVoteQuestion> list = mtVoteQuestionService.selectMtVoteQuestionList(mtVoteQuestion);
        return getDataTable(list);
    }

    /**
     * 导出投票问题列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, MtVoteQuestion mtVoteQuestion)
    {
        List<MtVoteQuestion> list = mtVoteQuestionService.selectMtVoteQuestionList(mtVoteQuestion);
//        ExcelUtil<MtVoteQuestion> util = new ExcelUtil<MtVoteQuestion>(MtVoteQuestion.class);
//        util.exportExcel(response, list, "投票问题数据");
    }

    /**
     * 获取投票问题详细信息
     */
    @GetMapping(value = "/{questionId}")
    public AjaxResult getInfo(@PathVariable("questionId") Long questionId)
    {
        return success(mtVoteQuestionService.selectMtVoteQuestionByQuestionId(questionId));
    }

    /**
     * 新增投票问题
     */
    @PostMapping
    public AjaxResult add(@RequestBody MtVoteQuestion mtVoteQuestion)
    {
        return toAjax(mtVoteQuestionService.insertMtVoteQuestion(mtVoteQuestion));
    }

    /**
     * 修改投票问题
     */
    @PutMapping
    public AjaxResult edit(@RequestBody MtVoteQuestion mtVoteQuestion)
    {
        return toAjax(mtVoteQuestionService.updateMtVoteQuestion(mtVoteQuestion));
    }

    /**
     * 删除投票问题
     */
	@DeleteMapping("/{questionIds}")
    public AjaxResult remove(@PathVariable Long[] questionIds)
    {
        return toAjax(mtVoteQuestionService.deleteMtVoteQuestionByQuestionIds(questionIds));
    }
}
